Step 4: Aggregate Query (`count_greater`)

The final command requires us to look at the entire network, not just one or two users.

Guidance for Step 4

  • `count_greater x`: Count how many users have a degree strictly greater than `x`.
  • Algorithm:
    1. Initialize `count = 0`.
    2. Loop through every user `i` from `0` to `U-1`.
    3. For each user, get their degree.
    4. If `degree > x`, increment `count`.
    5. Print the final `count`.
  • Your Task: Fill in the blanks to complete the final command.
...
    elif op == "count_greater":
        x = int(parts[1])
        count = 0

        # --- BLANK 5 ---
        # We must iterate through all U users.
        for i in _____________:
        
            # --- BLANK 6 ---
            # Get the degree of user i and check if it's > x.
            if _______________ > x:
                count += 1
                
        print(f"{count}")

                
Copied!